from selenium import webdriver
from selenium.webdriver.common.by import By
import time

class TestCase2:
    def __init__(self):
        self.driver=webdriver.Chrome()
        self.driver.get('https://mail.163.com')

    def register(self):
        # 跳转登录的frame页面
        time.sleep(5)
        s1=self.driver.find_element(By.TAG_NAME,'iframe')
        self.driver.switch_to.frame(s1)
        # self.driver.switch_to.frame('x-URS-iframe1652625041618.235')

        #输入账号密码
        self.driver.find_element(By.NAME,'email').send_keys('h66920@163.com')
        self.driver.find_element(By.NAME,'password').send_keys('h014..')
        self.driver.find_element(By.ID,'dologin').click()

    def sendEmail(self):
        #发送邮件

        self.driver.find_element(By.XPATH,'//*[@id="_mail_component_149_149"]/span[2]').click()
        self.driver.find_element(By.XPATH,'//*[@id="_mail_emailinput_0_285"]/input').send_keys('123')
        self.driver.find_element(By.XPATH, '//*[@id="1652628291966_subjectInput"]').send_keys('123')

        #进入内容frame
        s=self.driver.find_element(By.XPATH,'//*[@id="_mail_editor_0_290"]/div[1]/div[2]/iframe')
        self.driver.switch_to.frame(s)

        self.driver.find_element(By.XPATH, '/html/body').send_keys('123')
        self.driver.find_element(By.ID,'_mail_icon_41_294').click()

    def quit(self):
        time.sleep(2)
        self.driver.quit()


if __name__ == '__main__':
    case2=TestCase2()
    case2.register()
    # case2.sendEmail()
    case2.quit()
